package com.OjSystem.system.controller;

import com.OjSystem.common.core.result.CommonResult;
import com.OjSystem.system.service.ISysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sysUser")
@Tag(name = "管理员用户模块")
public class SysUserController {

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 测试接口
     *
     * @return
     */
    @RequestMapping("/test")
    public String test() {
        return "hello world";
    }


    /**
     * 管理员登录
     *
     * @param userAccount
     * @param password
     * @return
     */
    @PostMapping("/login")
    @Operation(summary = "登录", description = "使用账号和密码进行登录")
    @Parameters(value = {
            @Parameter(name = "userAccount", description = "传递的账号"),
            @Parameter(name = "password", description = "传递的密码"),
    })
    @ApiResponse(description = "返回是否可以进行登录")
    public CommonResult<String> login(String userAccount, String password) {
        return sysUserService.login(userAccount, password);
    }
}
